package com.cssy.yd.basic.service.impl;

import java.util.Date;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import org.springframework.stereotype.Service;

import com.byd.acegiext.domain.User;
import com.cssy.yd.basic.dao.BasicStorageinfoDAO;
import com.cssy.yd.basic.entity.BasicStorageinfoDO;
import com.cssy.yd.basic.service.IBasicStorageService;
import com.plat.exception.SyBaseException;
import com.plat.helper.SearchConditions;
import com.plat.helper.SearchResult;
import com.plat.util.IDCodeTypeUtil;


@Service("basicwhService")
public class BasicStorageServiceImpl implements IBasicStorageService{
	
	@Resource(name="basicStorageinfoDAO")	
	private BasicStorageinfoDAO basicstorageinfoDAO;
	
	
	@Override
	public SearchResult findListByExample(SearchConditions scs)
			throws SyBaseException {
		SearchResult rs=new SearchResult(scs);
		List<BasicStorageinfoDO>  list=basicstorageinfoDAO.find(scs);
		rs.setRecordCount(basicstorageinfoDAO.count(scs));
		rs.setResults(list);
		return rs;
	}

	@Override
	public Integer delete(String id, User user) throws SyBaseException {
		basicstorageinfoDAO.deleteBasicStorageinfoDOByPrimaryKey(id);
		return null;
	}

	@Override
	public Integer update(BasicStorageinfoDO t, User user) throws SyBaseException {
		t.setDuuser(user.getName());
		t.setDutime(new Date());
		return basicstorageinfoDAO.updateBasicStorageinfoDO(t);
	}

	@Override
	public BasicStorageinfoDO save(BasicStorageinfoDO t, User user)
			throws SyBaseException {
		t.setDcruser(user.getName());
		t.setDctime(new Date());
		t.setId(IDCodeTypeUtil.getId());
		basicstorageinfoDAO.insertBasicStorageinfoDO(t);
		return t;
	}

	@Override
	public BasicStorageinfoDO findListById(String id) throws SyBaseException {
		return basicstorageinfoDAO.findBasicStorageinfoDOByPrimaryKey(id);
	}
	

	@Override
	public List<BasicStorageinfoDO> findListByExample(BasicStorageinfoDO bhb)
			throws SyBaseException {
		return basicstorageinfoDAO.findListByExample(bhb);
	}

	@Override
	public BasicStorageinfoDO findByWhCode(String whCode) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public List<BasicStorageinfoDO> findwh(HttpServletRequest request)
			throws SyBaseException {
		SearchConditions scs = new SearchConditions();
		if(scs.getOrderBy()==null||"".equals(scs.getOrderBy()))
			 scs.setOrderBy("name");
		SearchResult st = this.findListByExample(scs);
		List<BasicStorageinfoDO> bclist = st.getResults();
		return bclist;
	}

	@Override
	public List<BasicStorageinfoDO> findwh() throws SyBaseException {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public List<String> getStorageinfoAndArea() throws SyBaseException {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public SearchResult findAllByExample(
			SearchConditions scs) throws SyBaseException {
		SearchResult rs=new SearchResult(scs);
		List<BasicStorageinfoDO>  list=basicstorageinfoDAO.findAll(scs);
		rs.setRecordCount(basicstorageinfoDAO.count(scs));
		rs.setResults(list);
		return rs;
	}

	@Override
	public Integer deleteBizRemoved(String id) throws SyBaseException {
		// TODO Auto-generated method stub
		return null;
	}
	
	

}
